package com.telsoft.data;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import com.telsoft.business.DAOHelperBusiness;
import com.telsoft.entity.LibraryEntity;
import java.util.ArrayList;

public class LibraryDAO {
public List<LibraryEntity> getLibrary() throws SQLException{
	List<LibraryEntity> librarys = new ArrayList<LibraryEntity>();
	Connection conn = DAOHelperBusiness.getConnection();
	Statement stm = DAOHelperBusiness.getStatement(conn);
	String sql = "SELECT * FROM LIBRARY";
	ResultSet rs = stm.executeQuery(sql);
	while (rs.next()){
		LibraryEntity lib = new LibraryEntity();
		lib.setLibID(rs.getInt("LIB_ID"));
		lib.setName( rs.getString("NAME"));
		lib.setCompany(rs.getString("COMPANY"));
		lib.setDetail(rs.getString("DETAIL"));
		lib.setVersion(rs.getString("VERSION"));
		librarys.add(lib);
	}
        DAOHelperBusiness.closeResultSet(rs);
	DAOHelperBusiness.closeStatement(stm);
	DAOHelperBusiness.closeConnection(conn);
	return librarys;
}
}
